package com.browsesoft;

import java.util.Hashtable;

import com.browsesoft.dbtools.DBTools;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2004
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author not attributable
 * @version 1.0
 */
public class LicenceTimeVerify implements Runnable {
	public static final String timeTableName = "t_dbmac";

	public LicenceTimeVerify() {
	}

	public void run() {
		while (true) {
			long currentTime = System.currentTimeMillis();
			Hashtable time = new Hashtable();
			time.put("f_time", currentTime + "");
			try {
				DBTools.update(timeTableName, "0", time);
			} catch (Exception ex1) {
			}
			try {
				Thread.sleep(180000);
			} catch (InterruptedException ex) {
			}
		}
	}

	public static boolean verifyTime() {
		try {
			String[][] times = DBTools
					.executeQueryWithTableHead("select f_time from "
							+ timeTableName + "");
			String time = times[1][0];
			long lastestTime = Long.parseLong(time);
			if (lastestTime - System.currentTimeMillis() < 0) {
				return true;
			}
		} catch (Exception ex) {
		}
		return false;
	}
}